using System;
using System.Web;
using System.Web.Configuration;
using DotSVN.Common.Util;
using DotSVN.Server.RepositoryAccess;

namespace DotSVN.WebSample
{
    public class Global : HttpApplication
    {
        private static ISVNRepository repository;

        public static ISVNRepository CurrentRepository
        {
            get { return repository; }
        }

        protected void Application_Start(object sender, EventArgs e)
        {
            string reposPath = "file://" + WebConfigurationManager.AppSettings["RepositoryPath"];
            repository = SVNRepositoryFactory.Create(new SVNURL(reposPath));
            repository.OpenRepository();
        }

        protected void Application_End(object sender, EventArgs e)
        {
            if (repository != null)
            {
                repository.CloseRepository();
            }
        }
    }
}